package com.kf.lib_network.http

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import java.util.concurrent.TimeUnit

abstract class BaseHttp {
    abstract fun connTime(): Long
    abstract fun writeTime(): Long
    abstract fun readTime(): Long

    fun createHttpBuilder(): OkHttpClient.Builder {
        val builder = OkHttpClient.Builder()
        builder.connectTimeout(connTime(), TimeUnit.SECONDS)
            .writeTimeout(writeTime(), TimeUnit.SECONDS)
            .readTimeout(readTime(), TimeUnit.SECONDS)
            .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
        return builder
    }
}